'''
写一个Python脚本实现找到/tmp目录及其子目录下的以.htm结尾的文件，把其后缀名改为.html
'''

import os

def rename_files(directory):
    for root, dirs, files in os.walk(directory):
        for file in files:
            if file.endswith(".htm"):
                file_path = os.path.join(root, file)
                new_file_path = os.path.splitext(file_path)[0] + ".html"
                os.rename(file_path, new_file_path)
                print(f"Renamed: {file_path} to {new_file_path}")

directory = r"c:\tmp"
print(directory)
rename_files(directory)



